<template>
<el-container style="height: 600px; border: 1px solid #eee">
                <el-header style="text-align: center; font-size: 20px, "> 个人中心</el-header>

  <el-container>
                <el-aside width="200px" style="background-color: rgb(238, 241, 246)">

                    <el-menu  router>
                        <el-menu-item  index="userinfo"><i class="el-icon-star-off"></i>个人信息</el-menu-item>
                        <el-menu-item  index="userinfoupdate"> <i class="el-icon-edit"></i>信息修改</el-menu-item>
                        <el-menu-item  index="userorder"><i class="el-icon-circle-check"></i>个人订单</el-menu-item>
                    </el-menu>

                    <el-button type="info"  icon="el-icon-switch-button" size="big"  @click="logoutHandler">退出登录</el-button>
                </el-aside>
    

                <el-main>
                <router-view></router-view>
                </el-main>
  </el-container>


</el-container>
</template>


<style>
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }
  
  .el-aside {
    color: #333;
  }
</style>

<script>
  export default {
    data() {
      const item = {
        date: '',
        name: '',
        address: ''
      };
      return {
        tableData: Array(20).fill(item)
      }
    },


    methods:{
    /**
     * 退出操作
     */
    logoutHandler() {
    
        this.$api.getLogOut({
                
                token: localStorage.getItem("loginToken")
            })
            .then(res => {
                if (res.data.status === 200) {
                    localStorage.removeItem("loginToken", null);
                    localStorage.removeItem("userid", null);
                    localStorage.removeItem("username", null);
                    localStorage.removeItem("phone",null);
                    localStorage.removeItem("email",null);
                    localStorage.removeItem("created",null);
                   // this.setUserId(null);
                    // this.removeCartCookie();
                    // this.setTokenActions(null);
                    // this.updateUsernameActions(null);
                    //clearCookie("CART_COOKIE_NAME");
                    // this.reload();
                    console.log(res);
                    this.$router.push({ path:'/' });
                } else {
                    alert("退出登陆失败");
                }
            });
    }

    }
   
  };
</script>